package tests;

import static org.junit.Assert.*;

import java.util.HashMap;
import java.util.LinkedList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import recipie.core.Ingredient;
import recipie.core.Recipie;
import recipie.core.RecipieCollection;
import recipie.core.Step;

public class RecipiesTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testIsertRecipiePresentInCollection() {
		RecipieCollection recipieCollection = new RecipieCollection();
		Recipie testRecipie = new Recipie("risotto", 2, true, 4, "cucchuaio d'argento", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		recipieCollection.instertRecipie(testRecipie);
		assertTrue(recipieCollection.containsValue(testRecipie));
	}
	@Test
	public void testRecipieCollectionNotEmptyAfterInsertion() {
		
		RecipieCollection recipieCollection = new RecipieCollection();
		Recipie testRecipie = new Recipie("risotto", 2, true, 4, "cucchuaio d'argento", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		recipieCollection.instertRecipie(testRecipie);
		assertFalse(recipieCollection.isEmpty());
	}
	
	@Test
	public void testRecipieWithSameNameNotIsterted() {
		
		RecipieCollection recipieCollection = new RecipieCollection();
		Recipie testRecipie = new Recipie("risotto", 2, true, 4, "cucchuaio d'argento", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		Recipie testRecipie2 = new Recipie("risotto", 4, true, 2, "mia madre", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		recipieCollection.instertRecipie(testRecipie);
		recipieCollection.instertRecipie(testRecipie2); 
	}
	
	@Test
	public void testSameRecipieNotIsterted() {
		
		RecipieCollection recipieCollection = new RecipieCollection();
		Recipie testRecipie = new Recipie("risotto", 2, true, 4, "cucchuaio d'argento", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		Recipie testRecipie2 = new Recipie("risotto", 2, true, 4, "cucchuaio d'argento", new HashMap<String, Ingredient>(), new LinkedList<Step>(), new RecipieCollection());
		recipieCollection.instertRecipie(testRecipie);
		recipieCollection.instertRecipie(testRecipie2);
	}
}
